
package com.wish.fantasy.amethyst;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Contacts;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

@SuppressWarnings("deprecation")
public class AmethystActivity extends Activity {

    private EditText name;
    private EditText phone;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn = (Button) findViewById(R.id.encode_contact);
        btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString(Contacts.Intents.Insert.NAME, name.getText().toString());
                bundle.putString(Contacts.Intents.Insert.PHONE, phone.getText().toString());
                encodeBarcode("CONTACT_TYPE", bundle);

            }

        });
        name = (EditText) findViewById(R.id.name);
        phone = (EditText) findViewById(R.id.phone);
    }

    private void encodeBarcode(String type, Bundle data) {
        Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
        intent.putExtra("ENCODE_TYPE", type);
        intent.putExtra("ENCODE_DATA", data);
        startActivity(intent);
    }
}
